package com.wxw.BaseLibrary.component.swipemenu;


import android.content.Context;
import android.graphics.drawable.Drawable;
import com.wxw.BaseLibrary.tool.SystemTool;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

/**
 * 
 * @author baoyz
 * @date 2014-8-23
 * 
 */
public class SwipeMenuItem {

	@Getter
	@Setter
	private int id;
	@Getter
	private Context mContext;
	@Getter
	@Setter
	private String title;
	@Getter
	private Drawable icon;
	@Getter
	private Drawable background;
	@Getter
	@Setter
	private int titleColor;
	@Getter
	@Setter
	private int titleSize;
	@Getter
	@Setter
	private int width;

	public SwipeMenuItem(Context context) {
		mContext = context;
	}

	public void setIcon(Drawable icon) {
		this.icon = icon;
	}

	public void setIcon(int resId) {
		this.icon = mContext.getResources().getDrawable(resId);
	}

	public void setBackground(Drawable background) {
		this.background = background;
	}

	public void setBackground(int resId) {
		this.background = mContext.getResources().getDrawable(resId);
	}

    public static SwipeMenuItem createMenuItem(Context context, int bcColor, int width, String title, int titleSize, int titleColor) {
        return createMenuItem(context, bcColor, width, title, titleSize, titleColor, -1);
    }

	public static SwipeMenuItem createMenuItem(Context context, int bcColor, int width, String title, int titleSize, int titleColor, int icon) {
        SwipeMenuItem item = new SwipeMenuItem(context);
        // set item background
        item.setBackground(bcColor);
        // set item width
        item.setWidth(SystemTool.dp2px(width, context));
        // set item title
        item.setTitle(title);
        // set item title fontsize
        item.setTitleSize(titleSize);
        // set item title font color
        item.setTitleColor(titleColor);
//                 set a icon
        if (icon > -1) {
            item.setIcon(icon);
        }
        return item;
    }
}
